package com.example.designpatterns.visitor;

public class VisitorDemo {
    public static void main(String[] args) {
        // 创建对象结构
        ObjectStructure objectStructure = new ObjectStructure();

        // 添加元素
        objectStructure.attach(new ElementA());
        objectStructure.attach(new ElementB());

        // 创建访问者
        Visitor visitor = new ConcreteVisitor();

        // 接受访问
        objectStructure.accept(visitor);
    }
} 